#ifndef __V_RESOURCE_H
#define __V_RESOURCE_H

#include "vglobal.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
mutex
*/
V_DECLEAR_HANDLE(vMutex);

vMutex vMutexCreate();
int vMutexLock(vMutex mtx);
int vMutexTrylock(vMutex mtx);
int vMutexUnlock(vMutex mtx);
int vMutexDestroy(vMutex mtx);

/**
cond
*/
V_DECLEAR_HANDLE(vCond);

vCond vCondCreate();
int vCondDestroy(vCond cnd);
int vCondSignal(vCond cnd);
int vCondBroadcast(vCond cnd);
int vCondWait(vCond cnd,vMutex mtx);
int vCondWaitTimeout(vCond cnd, vMutex mtx, int ms);


/**
spinlock
*/
V_DECLEAR_HANDLE(vSpin);

vSpin vSpinCreate();
int vSpinDestroy(vSpin spin);
int vSpinLock(vSpin spin);
int vSpinUnlock(vSpin spin);
int vSpinTrylock(vSpin spin);

/**
rwlock
*/
V_DECLEAR_HANDLE(vRwlock);

vRwlock vRwlockCreate();
int vRwlockRDlock(vRwlock lock);
int vRwlockWRlock(vRwlock lock);
int vRwlockUnlock(vRwlock lock);
int vRwlockDestroy(vRwlock lock);
int vRwlockTryrdlock(vRwlock lock);
int vRwlockTrywrlock(vRwlock lock);

/**
semaphore
*/
V_DECLEAR_HANDLE(vSem);

vSem vSemCreate();
int vSemDestroy(vSem sem);
int vSemPut(vSem sem);
int vSemPutTimeout(vSem sem,int ms);
int vSemGet(vSem sem);



#ifdef __cplusplus
}
#endif

#endif
